﻿<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" class="hb-loaded">
<head></head>
<body>
<link th:href="@{/css/shopping.css}" type="text/css" rel="stylesheet"/>
<script th:src="@{/js/jquery.js}" type="text/javascript"></script>
<script th:src="@{/js/shoppcart.js}" type="text/javascript"></script>
<script th:src="@{/layer/layer.js}"></script>
<title>购物车 - 提交订单</title>
<iframe src="javascript:false;" style="display: none;"></iframe>
<form id="aspnetForm" th:action="@{/dr_mall/drOrders/addOrder}" method="post" name="aspnetForm">
    <div th:each="cartid : ${cartId}">
        <input type="hidden" name="cartId" th:value="${cartid}">
    </div>
    <input type="hidden" name="skuId" th:value="${skuId}">
    <div>
        <input type="hidden"
               value="/wEPDwULLTEyMjU5Nzc3NTgPZBYCZg9kFgICAxBkZBYGZg8PFgIeBFRleHQFD+S9oOWlve+8gUtMTmdPa2RkAgEPFgIeBWNsYXNzBRRzaG9wX25hdiBzaG9wX25hdi1kZGQCAg9kFgRmDxYCHgtfIUl0ZW1Db3VudAIBFgJmD2QWAmYPFQkFNjE5MjESIGNoZWNrZWQ9ImNoZWNrZWQiG+emj+W7uuecgem+meWyqeW4gumVv+axgOWOvxLlqIPlqIPkurLliLDpnZLlspsG5byg5ZCICzEzODUxNDM1NTkzDOm7mOiupOWcsOWdgAU2MTkyMQU2MTkyMWQCAQ8WAh8CAgEWAmYPZBYCZg8VBRdGb3JldmVy57O75YiXIOe7j+WFuOasvgkxOEvnmb3ph5EBNxHntKDmnZDngasmaGVhcnRzOwYxMCw4MDBkZF0UgGn0DxQ3QCVr+e2vHjvosTt8"
               id="__VIEWSTATE" name="__VIEWSTATE"/>
    </div>
    <div>
        <input type="hidden" value="8C541494" id="__VIEWSTATEGENERATOR" name="__VIEWSTATEGENERATOR"/>
    </div>
    <!--全部背景-->
    <div class="all-thing">
        <!--中间内容-->
        <div class="tcmain">
            <!--头部-->
            <div class="shop_top">
                <div class="shopt_left fl">
                    <a title="Darry Ring" th:href="@{/}">
                        <img width="186" height="42" th:src="@{/images/dr.png}"/>
                    </a>
                    <span>求婚钻戒领导品牌</span>
                </div>
                <div class="shopt_right fr">
                    <span id="ctl00_ltlUname">你好！KLNgOk</span>
                    <a class="my_dr" href="member_index.html">我的DR</a>
                    <a onClick="javascript:logout()" class="tc_dr" href="#">退出</a>
                    <a class="help_dr" href="help.html">帮助中心</a>
                </div>
            </div>
            <!--头部end-->
            <!--导航条-->
            <div class="shop_nav shop_nav-dd" id="ctl00_showNav"></div>
            <!--导航条end-->
            <script type="text/javascript">
                function deleteAddress(id) {
                    if (confirm("确认是否删除？")) {
                    }
                }
                function addAddress() {
                    console.log("添加新地址");
                    location.href="http://192.168.6.100:8081/login.html";
                }
            </script>
            <!--内容-->
            <div class="shop_cort">
                <!--左边-->
                <div class="shop_cort-left fl">
                    <h3>收货人信息</h3>
                    <!--填写地址信息-->
                    <div class="shop_cort-adress">
                        <!--地址-->
                        <div class="shop_adress-top" th:each="address : ${addresses}">
                            <input type="radio" th:if="${address.status eq 'y'}" checked="checked" name="address"
                                   th:value="${address.id}" id="addressId"/>
                            <input type="radio" th:if="${address.status eq 'n'}" name="address"
                                   th:value="${address.id}"/>
                            <label style="width: 450px;display: inline-block">
                                <span th:text="${address.province}" style="padding: 0"></span>
                                <span th:text="${address.city}" style="padding: 0"></span>
                                <span th:text="${address.district}" style="padding: 0"></span>
                                <span th:text="${address.address}" style="padding: 0"></span>
                            </label>
                            <label style="display: inline-block;width: 175px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span style="padding: 0" th:text="${address.receiver}">张合</span><span
                                        style="padding: 0">(收)</span>
                                <span style="padding: 0" th:text="${address.telephone}">13851435593</span>
                            </label>
                        </div>
                        <div class="shop_adress-top">
                            <label class="adress_color">
                                <a href="javascript:void(0)" onclick="addAddress()">添加新地址</a>
                            </label>
                        </div>
                        <!--地址end-->
                        <div class="shop_adress-qr">
                            <div class="shop_adressqr-top">
                                <a class="fr" th:href="@{/dr_mall/drCart/cartList}">返回修改购物车&gt;&gt;</a>
                                <span>确认订单信息</span>
                                <i>提示：专属订制产品，需要相关证书认证时间。建议尽快提交。</i>
                            </div>
                            <!--订单-->
                            <table cellspacing="0" cellpadding="0" border="0" class="shop_adressqr-of">
                                <tbody>
                                <tr class="shop_adressqr-first">
                                    <td class="shop_adress-shoop">商品图片</td>
                                    <td class="shop_adress-cz">商品名称</td>
                                    <td class="shop_adress-sc">规格型号</td>
                                    <td class="shop_adress-pirce">价 格</td>
                                    <td class="shop_adress-kz"></td>
                                </tr>
                                <!--从购物车获取的信息-->
                                <tr class="shop_adressqr-sec" th:each="cart : ${carts}">
                                    <td class="shop_adress-shoop">
                                        <img width="85" height="85" th:src="${cart.skus.products.picture.image}">
                                    </td>
                                    <td class="shop_adress-cz" th:text="${cart.skus.products.name}">18K白金</td>
                                    <td class="shop_adress-sc" th:text="${cart.skus.specVal}">7</td>
                                    <td class="shop_adress-pirce">
                                        <span th:text="${cart.price}" style="font-family:微软雅黑"
                                              class="price">￥10,800</span>
                                    </td>
                                    <td class="shop_adress-kz"></td>
                                </tr>
                                <!--从商品详情获取的信息-->
                                <tr class="shop_adressqr-sec" th:if="${sku ne null}">
                                    <td class="shop_adress-shoop">
                                        <img width="85" height="85" th:src="|/${sku.products.picture.image}|">
                                    </td>
                                    <td class="shop_adress-cz" th:text="${sku.products.name}">18K白金</td>
                                    <td class="shop_adress-sc" th:text="${sku.specVal}">7</td>
                                    <td class="shop_adress-pirce">
                                        <span th:text="${sku.price}" style="font-family:微软雅黑"
                                              class="price">￥10,800</span>
                                    </td>
                                    <td class="shop_adress-kz"></td>
                                </tr>
                                </tbody>
                            </table>
                            <!--订单end-->
                            <!--总计-->
                            <div class="shop_adress-zj">
                                <div class="fl">
                                    <span>总计</span>
                                </div>
                                <div class="fr">
                                    <i id="count" th:text="${carts.size()}">1</i>
                                    <span>件商品</span>
                                    <span>应付金额：
                                        <i style="font-family:微软雅黑" class="fw_bold" id="totalPrice">10,800</i>
                                    </span>
                                </div>
                            </div>
                            <!--总计-->
                            <!--最后一块-->
                            <div class="shop_adress-last">
                                <div onClick="submitOrder();" class="shop_adress-tjdd fr">
                                    <div class="bt1 fr">
                                        <span>立即提交订单</span>
                                    </div>
                                </div>
                            </div>
                            <!--最后一块end-->
                        </div>
                    </div>
                    <!--填写地址信息end-->
                </div>
                <!--左边end-->
                <!--右边-->
                <!--右边-->
                <div class="shop_cort-right fr">
                    <div class="shop_right-nr">
                        <h3>购物帮助指南</h3>
                        <div class="shop_right-zx line_bottom">
                            <p class="shop_lx">24小时在线客服</p>
                            <p class="shop_tel">400-01-13520</p>
                        </div>
                        <div class="shop_right-zf line_bottom">
                            <h4>支付安全保障</h4>
                            <p>安全支付系统采用SSL加密。</p>
                            <ul class="shop_right-ul">
                                <li class="shop_cor-yl"></li>
                                <li class="shop_cor-cft"></li>
                                <li class="shop_cor-zf"></li>
                            </ul>
                        </div>
                        <div class="shop_right-ps">
                            <h4>全球配送</h4>
                            <p class="shop_kd">支持全球配送,店铺取货</p>
                            <p class="shop_bj">全程保价 无风险</p>
                        </div>
                    </div>
                </div>
                <!--右边end-->
                <!--右边end-->
            </div>
            <!--内容end-->
            <!--底部-->
            <div class="cmain shop_foot">
                <p>Copyright &copy; 2006-2015 www.darryring.com 戴瑞珠宝 All Rights Reserved. 粤ICP备11012085号</p>
                <p>中国互联网违法信息举报中心 | 中国公安网络110报警服务 | 本网站提供所售商品的正式发票</p>
                <div class="shop_foot-img">
                    <img width="776" height="55" th:src="@{/images/db.jpg}"/>
                </div>
            </div>
            <!--底部end-->
        </div>
        <!--全部背景end-->
    </div>

    <script type="text/javascript">
        function logout() {
            if (window.confirm('确定退出吗？')) {
                $.get("/nAPI/QuitExit.ashx", function (data) {
                    window.location.href = "/";
                });
            }
        }
    </script>
</form>
<script>
    $(function () {
        calculation();
    })

    function submitOrder() {
        console.log($("#addressId").length);

        if ($("#addressId").length > 0){
            $("#aspnetForm").submit();
        }else{
            layer.msg("请添加地址");
        }
    }

    function calculation() {
        // 总价
        let total = 0;
        let count=$("#count").text();
        if ($("#count").text()==0){
            count=1;
        }
        $("#count").text(count);
        $(".price").each(function () {
            //找到当前点击的商品的价格
            let oneProductPrice = $(this);
            //计算被选中的商品的价格
            total += Number(oneProductPrice.text());
        });
        //替换商品总价
        $("#totalPrice").text(total.toFixed(2) + "￥");
    }
</script>

</body>
</html>